<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML>
<html lang="zh-CN">
  <head>
 
     <base href="<%=basePath%>">
     <meta charset="utf-8">
     <meta http-equiv="X-UA-Compatible" content="IE=edge">
     <meta name="viewport" content="width=device-width, initial-scale=1">
 
     <title>图纸管理</title>

     <script type="text/template"  id="teamList">
		<|  for(var i = 0; i<list.length;i++){
		       var item = list[i];
		|>
 
			        <tr>
			          <th scope="row"><|=item.partsNo |> </th>
			          <td><|=item.partsName |></td>
			          <td><|=item.cartypeName |></td>
			          <td>
                        <| if(item.programmeid!=null){ |>
			               	<span class="state state-1"></span>
                        <|}if(item.productid!=null){ |>
			          	    <span class="state state-2"></span>
                        <|}if(item.modleid!=null){ |>
			          	    <span class="state state-3"></span>
                        <|}|>
					  </td>
					   <td class="console-action">
			          	<a href="javascript:updateStatus(<|=item.id|>,1);" class="<|=item.status==1? 'action-active':'' |>">上架</a>
			          	<a href="javascript:updateStatus(<|=item.id|>,0);" class="<|=item.status==0? 'action-active':'' |>">下架</a>
			          </td>
					   <td class="console-action">
			          	<a href="javascript:showUploadDialog(<|=item.id|>,'<|=item.programmeid|>','<|=item.productid|>','<|=item.modleid|>');">上传图纸</a>
			            <a href="javascript:showDownloadDialog('<|=item.programmeid|>','<|=item.productid|>','<|=item.modleid|>');">下载图纸</a>
			          </td>
			        </tr>
 
		 <|}|>
 
	</script>
 
      <jsp:include page="../common/console.jsp"></jsp:include>
      <script src="<%=request.getContextPath() %>/resources/js/system/drawing/drawing_list.js" type=text/javascript></script> 
    
  </head>
  
  <body class="console-body"  id="loading">
  		   
  	<div class="console-list">
  		<div class="console-listSolid">&nbsp;</div>
  		<div class="console-listContent">
	  		<div class="console-listHead clearfix">
				<form class="navbar-form navbar-left" role="search" action="after/drawing/drawing_list" id="drawingform">
					<div class="form-group">
					 	<input type="text" class="form-control" name="partsName" placeholder="零件名称..." value="${param.partsName}">
					 	<input type="hidden" class="form-control" name="carid" id="carid"  value="${param.carid}">
					 	<input type="hidden" class="form-control" name="partsType" id="partsType"  value="${param.partsType}">
					</div>
					<button type="submit" class="btn btn-default">搜索</button>
				</form>
				
				<span class="dm-dropTitle">车型</span>
				<div class="dropdown dm-dropBtn">
				  <button class="btn btn-default dropdown-toggle" type="button" id="dropdownMenu" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
				    <span id="dropBtnContent">全部</span>  
				    <span class="caret"></span>
				  </button>
				  <ul id="dm-dropUl" class="dropdown-menu" aria-labelledby="dropdownMenu">
				  </ul>
				</div>
	  		</div>
	  	
	  		<div class="console-listTable">
		  		<table class="table table-hover">
			      <thead>
			        <tr>
			          <th>零件号</th>
			          <th>零件名称</th>
			          <th>对应车型</th>
			          <th>图纸状态</th>
			          <th>上下架</th>
			          <th>操作</th>
			        </tr>
			      </thead>
			      
			        <tbody id="container" ></tbody>
			        
			    </table>
			    
				<nav class="clearfix">
					<c:if test="${datas.total > 0}">
						<jsp:include page="/jsp/pager.jsp">
							<jsp:param value="${datas.total}" name="totalRecord"/>
							<jsp:param value="after/drawing/drawing_list" name="url"/>
						</jsp:include>
					</c:if>
				</nav>
		    </div>
  		</div>
  	</div><!-- console-list -->
  	
  	<!-- Modal -->
	<div class="modal fade dm-uploadModal" id="dm-uploadModal" tabindex="-1" role="dialog" aria-labelledby="dm-uploadModalLabel" data-backdrop="static">
	  <div class="modal-dialog" role="document">
	    <form id="fileform" action="after/drawing/update">
 
	    	<input type="hidden" name="programmeid" id="programmeid">
	    	<input type="hidden" name="productid" id="productid">
	    	<input type="hidden" name="modleid" id="modleid">
	    	<input type="hidden" name="id" id="partsid">
		    <div class="modal-content">
		      <div class="modal-header">
		        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
		        <h4 class="modal-title" id="myModalLabel">上传相关图纸</h4>
		      </div>
		      
		      <div class="modal-body console-modalBody">
		        <div>
	        		<label>编程图</label>
					<input type="file" class="file" name="programmeFile" id="programmeFile">
					<input type="button" value="上传" onclick="upload('编程图','programme')">
		        </div>
		        <div>
	        		<label>产品制作图</label>
					<input type="file" class="file" name="productFile" id="productFile">
					<input type="button" value="上传" onclick="upload('产品制作图','product')">
		        </div>
		        <div>
	        		<label>模具图</label>
					<input type="file" class="file" name="modleFile"  id="modleFile">
					<input type="button" value="上传"  onclick="upload('模具图','modle')">
		        </div>
		        <div class="dm-modalHint" style="display: none">目前仅支持.stp格式文件上传</div>
		      </div>
		      
		      <div class="modal-footer">
		        <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
		        <button type="submit" class="btn btn1">确定</button>
		      </div>
		    </div>
	     </form>
	  </div>
	</div>
	
	
		<!-- Modal -->
	<div class="modal fade dm-downloadModal" id="dm-downloadModal" tabindex="-1" role="dialog" aria-labelledby="dm-downloadModal" data-backdrop="static">
	  <div class="modal-dialog" role="document">
	    <form id="fileform" action="after/drawing/update">
 
		    <div class="modal-content">
		      <div class="modal-header">
		        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
		        <h4 class="modal-title" id="myModalLabel">下载相关图纸</h4>
		      </div>
		      
		      <div class="modal-body console-modalBody">
		        <div>
                    <label>编程图</label> 
                    <a href="" id="programmeFile">下载</a>
		        </div>
		        <div>
	     
					 <label>产品制作图</label> 
					 <a href="" id="productFile">下载</a>
		        </div>
		        <div>
					 <label>模具图</label> 
					 <a href="" id="modleFile">下载</a>
		        </div>
		        <div class="dm-modalHint" style="display: none">目前仅支持.stp格式文件上传</div>
		      </div>
		      
		      <div class="modal-footer">
		        <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
		        <button type="submit" class="btn btn1">确定</button>
		      </div>
		    </div>
	     </form>
	  </div>
	</div>
  	<script type="text/javascript">
  	            
	  $.ajax({  
	        type : "POST",  
	        url : CONTEXT_PATH+'common/selectByComboCategory?category=Car',  
	        dataType : "json",  
	        cache : false,  
	        async : false,  
	        success : function(data) {  
 
	            var optionStr = '';  
	            for (var i = 0; i < data.length; i++) {  
	                
	                if('${param.carid}'==data[i].value+''){
	                   $("#dropBtnContent").html(data[i].text);
	                }
	                optionStr += "<li><a href=javascript:query("+data[i].value+")>"+data[i].text+"</a></li>";  
	            }  
	            $("#dm-dropUl").html("<li><a href=javascript:query(null)>全部</a></li>" + optionStr);  
	        }  
	    }); 
  	
  	</script>
  	
  </body>
</html>
